<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
		<script src="../../js/class/jquery-3.0.0.min.js"></script>
	</head>
	<body>



		<script type="text/javascript">
			function pySegSort(arr, empty) {
				if (!String.prototype.localeCompare)
					return null;
				var letters = "*abcdefghjklmnopqrstwxyz".split('');
				var zh = "阿八嚓哒妸发旮哈讥咔垃痳拏噢妑七呥扨它穵夕丫帀".split('');
				var segs = [];
				var curr;
				$.each(letters, function(i) {
					curr = {
						letter: this,
						data: []
					};
					$.each(arr, function() {
						if ((!zh[i - 1] || zh[i - 1].localeCompare(this, "zh") <= 0) && this.localeCompare(zh[i], "zh") == -1) {
							curr.data.push(this);
						}
					});
					if (empty || curr.data.length) {
						segs.push(curr);
						curr.data.sort(function(a, b) {
							return a.localeCompare(b, "zh");
						});
					}
				});
				console.log(segs)
				return segs;
			}
			JSON.stringify(pySegSort(["我", "不", "懂", "爱", "啊", "按", "已", "呀", "选", "县"]))
		</script>
	</body>
</html>
